import { reqGetSearchList } from "@/api";
const state = {
    searchList:{}
};
const mutations = {
    GETSEARCHLIST(state,searchList){
        state.searchList=searchList
    }
};
const actions = {
    //params至少是一个空对象
    async getSearchList({ commit }, params = {}) {
        let result = await reqGetSearchList(params)
        if (result.code == 200) {
            commit("GETSEARCHLIST", result.data)
        }
    }
};
const getters = {
    //state为当前仓库中的state，不是大仓库
    goodsList(state){
        //假如网络有问题时，返回的时undinfiend，但是应该至少是一个数组
        return state.searchList.goodsList || [];
    },
    attrsList(state){
        return state.searchList.attrsList|| [];
    },
    trademarkList(state){
        return state.searchList.trademarkList|| [];
    }
};
export default {
    state,
    mutations,
    actions,
    getters
}